#include <iostream>
#include <unistd.h>
#include <pthread.h>

using namespace std;

// 1. 线程谁先运行与调度器相关
// 2. 线程一旦异常，都可能导致整个进程整体退出
void *threadRoutine(void* args){
    while(true){
        cout << "新线程：" << (char*)args << " running ..." << endl;
        sleep(1); 

        int a = 100;
        a /= 10;
        a /= 0;                 // 注意此处：测试特点：2. 线程一旦异常，都可能导致整个进程整体退出

    }
}

int main(){

    pthread_t tid;
    pthread_create( &tid , nullptr, threadRoutine, (void*)"thread 1");

    while(true){
        cout << "main 线程：" << " running ..." << endl;
        sleep(1); 
    }

    return 0;
}